package com.zrf.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zrf.dao.impl.CheckDaoImpl;
import com.zrf.dao.impl.ManifestDaoImpl;
import com.zrf.dao.impl.ProductDaoImpl;
import com.zrf.dao.impl.StorageDaoImpl;
import com.zrf.pojo.Product;
import com.zrf.pojo.Storage;
import com.zrf.pojo.User;

@Service("logoService")
public class LogoService {
	@Autowired
	private StorageDaoImpl sdi;
	@Autowired
	private ProductDaoImpl pdi;
	@Autowired
	private ManifestDaoImpl ldi;
	@Autowired
	private CheckDaoImpl cdi;
	
	public void addLogo(Integer sid, Integer toSid, Integer pid, Integer pnum, User user) {
		try {
			Product pro = pdi.findById(pid);
			if (pro.getPnum()>=pnum) {
				Storage sto = sdi.findById(sid);
				Storage toSto = sdi.findById(toSid);
				ldi.addLogo(sto,toSto,pro,pnum,user);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block

			e.printStackTrace();
		}
	}

	public void addToAddress(Integer sid, String address, int pid, int pnum,
			User user) {
		// TODO Auto-generated method stub

		try {
			Product pro = pdi.findById(pid);
			if (pro.getPnum()>=pnum) {
				Storage sto = sdi.findById(sid);
				ldi.addLogo(sto,address,pro,pnum,user);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block

			e.printStackTrace();
		}
	}
	
}